@extends('layouts.back_stage')
@section('style')
    <link rel="stylesheet" href="{{env('CDN_DOMAIN_NAME')}}/css/clothInfo.css"/>
    <style>
        .print_head{
            width:100%;
            margin:0 auto;
            padding-top:20px;
            padding-bottom:20px;
            overflow: hidden;
        }
        .print_head button{
            float:right;
            margin:5px;
        }
        .print_info_box{
            width:100%;
        }
        .print_info_box li{
            width:33%;
            float:left;
            height:40px;
        }
        .print_info_box li h3{
            display: inline-block;
        }
        .print_info_box li span{
            border-bottom:1px solid #cccccc;
            padding-left:12px;
        }
    </style>
@section('content')
    <div class="container">
        <div class="print_head"><button class="btn btn-success" onclick="print_page()">打印</button><button class="btn btn-info" onclick="back_print()">返回</button></div>
        <!--startprint-->
        <ul class="print_info_box">
            <li>
                <h3>供应商:</h3><span>{{$purchase->supplier_name}}</span>
            </li>
            <li>
                <h3>合同号:</h3><span>{{ $purchase->contract_code }}</span>
            </li>
            <li>
                <h3>合同签订人:</h3><span>{{$purchase->contract_name}}</span>
            </li>
            <li>
                <h3>销售季节:</h3><span>{{$purchase->season}}</span>
            </li>
            <li>
                <h3>下达日期:</h3><span>{{$purchase->purchase_date}}</span>
            </li>
            <li>
                <h3>采购类型:</h3><span>
                    @if($purchase->purchase_status==1)
                        计划采购
                    @elseif($purchase->purchase_status==2)
                        提前采购
                    @endif
                </span>
            </li>
            <li>
                <h3>服务款号:</h3><span>{{$purchase->to_girard}}</span>
            </li>
            <li>
                <h3>备注:</h3><span>{{$purchase->remarks}}</span>
            </li>
            <li>
                <h3>数量:</h3><span>{{$purchase->num}}</span>
            </li>
            <li>
                <h3>金额:</h3><span>{{$purchase->price}}</span>
            </li>
        </ul>
        <table class="pantone" border="1" cellspacing="0" cellpadding="0">
            <tr>
                <td>面辅料号</td><td>颜色</td><td>投产需求量</td><td>物控量</td><td>采购量</td><td>单位</td><td>采购价</td><td>金额</td><td>成分</td><td>备注</td>
            </tr>
            @if(count($purchase_details) > 0)
                @foreach($purchase_details as $v)
                    <tr>
                        <td >{{ $v->cloth_code }}</td>
                        <td>{{ $v->color }}</td>
                        <td >{{ $v->demand }}%</td>
                        <td>{{ $v->control }}</td>
                        <td >{{ $v->purchase }}</td>
                        <td >{{ $v->unit }}</td>
                        <td >{{ $v->purchase_price }}</td>
                        <td >{{ $v->total_price }}</td>
                        <td >{{ $v->info }}</td>
                        <td >{{ $v->remarks }}</td>
                    </tr>
                @endforeach
            @endif
        </table>
        <!--endprint-->
    </div>
    <script type="text/javascript">
        function print_page() {
            var bdhtml = window.document.body.innerHTML;//获取当前页的html代码
            var startStr = "<!--startprint-->";//设置打印开始区域
            var endStr = "<!--endprint-->";//设置打印结束区域
            var printHtml = bdhtml.substring(bdhtml.indexOf(startStr) + startStr.length, bdhtml.indexOf(endStr));//从标记里获取需要打印的页面
            window.document.body.innerHTML = printHtml;//需要打印的页面
            window.print();
            window.document.body.innerHTML = bdhtml;//还原界面
        }
        function back_print() {
            window.location.href="/purchase/purchaseList";
        }
    </script>
@endsection
